﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tbHOADON_BANGKEHOADON_DETAIL
/// </summary>
public class cls_tbHOADON_BANGKEHOADON_DETAIL
{
	public cls_tbHOADON_BANGKEHOADON_DETAIL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static DataTable GetByF_STTF_KyHieuHDF_SoHD(Guid F_STT, string F_KyHieuHD, string F_SoHD)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_STT, F_KyHieuHD, F_SoHD };
        string[] parameters = { "@F_STT", "@F_KyHieuHD", "@F_SoHD" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_DETAIL_GetByF_STTF_KyHieuHDF_SoHD", para);
            //dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_DETAIL_GetAll", null);
        }
        catch { }
        return dt;
    }
    public static DataTable GetByF_STTF_KyHieuHDF_SoHD_STT(Guid F_STT, string F_KyHieuHD, string F_SoHD,int STT)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_STT, F_KyHieuHD, F_SoHD, STT };
        string[] parameters = { "@F_STT", "@F_KyHieuHD", "@F_SoHD", "@STT" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_DETAIL_GetByF_STTF_KyHieuHDF_SoHD_STT", para);
            //dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_DETAIL_GetAll", null);
        }
        catch { }
        return dt;
    }
    //public static DataTable GetByF_MaCN_GetGroup(string F_MACN)
    //{
    //    DataTable dt = new DataTable();
    //    DatabaseConnect connect = new DatabaseConnect();
    //    // Tham so
    //    SqlParameter[] para = new SqlParameter[1];
    //    para[0] = new SqlParameter("@F_MACN", F_MACN);
    //    try
    //    {
    //        dt = connect.GetSelectCommand("tbHOADON_BANGKEHOADON_GetByF_MACN_GetGroup", para);
    //    }
    //    catch { }
    //    return dt;
    //}
    public static string Insert(Guid F_STT, string F_KyHieuHD, string F_SoHD, int STT, string F_tenhanghoa, string F_donvitinh, int F_soluong, int F_dongia, int F_thanhtien)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_STT, F_KyHieuHD, F_SoHD, STT, F_tenhanghoa, F_donvitinh, F_soluong, F_dongia, F_thanhtien };
        string[] parameters = { "@F_STT", "@F_KyHieuHD", "@F_SoHD", "@STT", "@F_tenhanghoa", "@F_donvitinh", "@F_soluong", "@F_dongia", "@F_thanhtien" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tbHOADON_BANGKEHOADON_DETAIL_insert", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
    public static string Update(Guid F_STT, string F_KyHieuHD, string F_SoHD, int STT, string F_tenhanghoa, string F_donvitinh, int F_soluong, int F_dongia, int F_thanhtien)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_STT, F_KyHieuHD, F_SoHD, STT, F_tenhanghoa, F_donvitinh, F_soluong, F_dongia, F_thanhtien };
        string[] parameters = { "@F_STT", "@F_KyHieuHD", "@F_SoHD", "@STT", "@F_tenhanghoa", "@F_donvitinh", "@F_soluong", "@F_dongia", "@F_thanhtien" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tbHOADON_BANGKEHOADON_DETAIL_update", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
}